<?php
/**
 * 
 */

namespace Api\Controller;
use Think\Controller;






class IndexController extends Controller {
 //    	function __construct() {
	// 	parent::__construct();
	// 	$token=I("request.token");
	// 	if(!empty($token)){
	// 		if($token!=='ydxzoa'){
			
	// 			echo json_encode(array('code' => '2', 'message' => 'token错误'));
	// 			exit;
	// 		}
	// 	}else{
	// 			echo json_encode(array('code' => '3', 'message' => '该请求无token'));
	// 			exit;
	// 	}

	// }


	/**
	 * 登入控制器
	 * @return [name] [用户名]
	 * @return [pass] [密码]
	 */
	public function login()
	{
		// dump(I());
		// exit;
		$pass= $_REQUEST['pass'];
		$pass = password($pass);
		$user= $_REQUEST['name'];
		// $list = M("member")->where(['user'=>$user,'password'=>$pass])->find();
		$list = M('member')->join('oa_auth_group_access as t1 on t1.uid = oa_member.uid')->join('oa_auth_group as t2 on t2.id = t1.group_id')->where(['oa_member.user'=>$user,'oa_member.password'=>$pass])->select();
		// dump($list);
		// exit;
		$ulist['id'] = $list[0]['uid'];
		$ulist['uname'] = $list[0]['user'];
		// $ulist['upost'] = $list[0]['upost'];
		$ulist['m_type'] = $list[0]['m_type'];
		$ulist['ment'] = $list[0]['title'];
		$ulist['j_type'] = $list[0]['mtype'];
		// dump($list);
		// exit;
		if (empty($list)) {
			echo json_encode(array("status"=>2,'message'=>'用户不存在',"data"=>[]));
					exit;
		}else{
			echo json_encode(array("status"=>1,'message'=>'请求成功',"data"=>$ulist));
					exit;
		}
		// echo $pass;
	}


	/**
	 * [users 用户展示列表]
	 * @return [type] [description]
	 */
	public function users()
	{
		$page = isset($_REQUEST['page'])?$_REQUEST['page']:1;
		// $page= page ？？ 1

		//查询总条数
		$count = M('member')->count();
		// echo $count;
		// exit;
		//每页显示数
		$pageSize = 10;
		//计算总页数
		$a = ceil($count / $pageSize);
		if ($page > $a) {
			$page = $a;
		}
		//sql查询起始位置
		$start = ($page - 1) * $pageSize;
		//得到数据
		$list = M('member')->order("upost asc")->limit("$start,$pageSize")->select();
		
		if (!empty($list)) {
			
			$array = array(
				"status"=>1,
				'message'=>'请求成功',
				"count"=>$count,//总条数
				"pageSize"=>$pageSize, //每页显示条数
				"thisPage"=>$page, //当前页码
				"data"=>$list//列表
				);
			echo json_encode($array);
			exit;
		}else{
			echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
			exit;
		}
	}


	/**
	 * 库存列表分页展示
	 * @return [page] [页数]
	 */
	public function kindex()
	{
		$page = isset($_REQUEST['page'])?$_REQUEST['page']:1;
		// $page= page ？？ 1

		//查询总条数
		$count = M('stock')->count();
		// echo $count;
		// exit;
		//每页显示数
		$pageSize = 10;
		//计算总页数
		$a = ceil($count / $pageSize);
		if ($page > $a) {
			$page = $a;
		}
		//sql查询起始位置
		$start = ($page - 1) * $pageSize;
		//得到数据
		$list = M('stock')->order("id asc")->limit("$start,$pageSize")->select();
		
		if (!empty($list)) {
			
			$array = array(
				"status"=>1,
				'message'=>'请求成功',
				"count"=>$count,//总条数
				"pageSize"=>$pageSize, //每页显示条数
				"thisPage"=>$page, //当前页码
				"data"=>$list//列表
				);
			echo json_encode($array);
			exit;
		}else{
			echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
			exit;
		}

	}


	/**
	 * 库存搜索
	 * @return [name] [物品名]
	 */
	public function ksou()
	{
		// dump(I());
        $list = $_GET;
        $name = $list['name'];
        
        $cname['name']= array('like','%'.$name.'%');

        $wlist = M('stock')->where($cname)->select();
        // dump($wlist);
        // exit;
        if (!empty($wlist)) {
             // $arr = M('stock')->where($data)->select();
            echo json_encode(array("status"=>1,'message'=>'请求成功',"data"=>$wlist));
			exit;
        }else{
          	echo json_encode(array("status"=>0,'message'=>'物品名不存在',"data"=>[]));
			exit;
        }
	}





	/**
	 * 库存修改
	 * @return [pid] [物品Id]
	 * @return [num] [数量]
	 * @return [unit] [单价]
	 */
	public function edit()
	{
		$pid = $_GET['pid'];
		$list['unit'] = $_GET['unit'];
		$list['number'] = $_GET['num'];
		// dump($pid);
		// exit;
		if (M('stock')->where(['id'=>$pid])->save($list) > 0) {
			echo json_encode(array("status"=>1,'message'=>'修改成功',"data"=>$list));
			exit;
		}else{
			echo json_encode(array("status"=>0,'message'=>'修改失败',"data"=>[]));
			exit;
		}
	}



	/**
	 * 库存删除
	 * @return [pid] [物品Id]
	 */
	public function del()
	{
		$pid = $_GET['pid'];
    	if (M('stock')->where(['id'=>$pid])->delete() > 0) {
    		echo json_encode(array("status"=>1,'message'=>'删除成功',"data"=>$pid));
			exit;
    		
    	}else{
    		echo json_encode(array("status"=>0,'message'=>'删除失败',"data"=>[]));
			exit;
    	}
	}





	/**
	 * [bcalss 办公用品分类]
	 * @return [type] [类型: 1:办公用品; 2:劳保用品; 3:招待用品]
	 * @return [page] [页数]
	 */
	public function bcalss()
	{
		
		$page = isset($_REQUEST['page'])?$_REQUEST['page']:1;
		$type = $_REQUEST['type'];
		// $page= page ？？ 1

		//查询总条数
		$count = M('stock')->count();
		// echo $count;
		// exit;
		//每页显示数
		$pageSize = 20;
		//计算总页数
		$a = ceil($count / $pageSize);
		if ($page > $a) {
			$page = $a;
		}
		//sql查询起始位置
		$start = ($page - 1) * $pageSize;
		//得到数据
		$list = M('stock')->where(['x_type'=>$type])->order("id asc")->limit("$start,$pageSize")->select();
		// dump($list);
		// exit;
		if (!empty($list)) {
			
			$array = array(
				"status"=>1,
				'message'=>'请求成功',
				"count"=>$count,//总条数
				"pageSize"=>$pageSize, //每页显示条数
				"thisPage"=>$page, //当前页码
				"data"=>$list//列表
				);
			echo json_encode($array);
			exit;
		}else{
			echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
			exit;
		}

	}







	/**
	 * [bsou 办公用品申请信息搜索]
	 * @return [name] [物品名称]
	 */
	public function bsou()
	{
		// dump(I());
	      $list = $_GET;
	      $name = $list['name'];
	      // dump($list);
	      // exit;

	      // $data['name']= array('like','%'.$name.'%');
	      $cname['name']= array('like','%'.$name.'%');
	      // $data['x_type'] = $list['x_type'];
	      // if (empty($wname)) {
	      //   echo '1111';
	      //   exit;
	      // }
	      $wlist = M('stock')->where($cname)->select();
	      if (!empty($wlist)) {
		        echo json_encode(array("status"=>1,'message'=>'请求成功',"data"=>$wlist));
				exit;
	      }else{
		        echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
				exit;
	      }
	}






	/**
	 * [badd 办公用品申请/月度需求申请]
	 * @return [pid] [物品id]
	 */
	public function badd()
	{

		// dump(I());
		// exit;
		$ku = M('stock')->where(['id'=>$_GET['id']])->find();
      	if ($_GET['type'] == '0') {
      		if ($_GET['num'] > $ku['number']) {
		        echo json_encode(array("status"=>3,'message'=>'申请数量超过库存数量',"data"=>[]));
				exit;
		    }else if(empty($ku)){
		    	echo json_encode(array("status"=>4,'message'=>'物品不存在',"data"=>[]));
				exit;
		    }

      	}
        $dada = M('member')->where(array('uid'=>$_GET['uid']))->select();

        // dump($dada);
        $z_id = M('auth_group_access')->where(array('uid'=>$_GET['uid']))->select();
        
        $b_id = $z_id[0]['group_id'];
        $m_list = M('auth_group')->where(array('id'=>$b_id))->select();
        $slist = M('stock')->where(['id'=>$_GET['id']])->select();
        // dump($m_list);
        // exit;
        switch ($ku['x_type']) {
          case '1':
            $arr['x_type'] = '办公用品';
            $date['wtype'] = '办公用品';
            break;
          case '2':
            $arr['x_type'] = '劳务用品';
            $date['wtype'] = '劳务用品';
            break;
          case '3':
            $arr['x_type'] = '招待用品';
            $date['wtype'] = '招待用品'; 
            break;
        }
       
        // dump($dada[0]['m_type']);
        // exit;
        switch ($dada[0]['m_type']) {
              case '2':  //主管
                    // dump($_POST);
                    // exit;
                    if ($m_list[0]['post'] == '行政中心') {
                        
                        $arr['num'] = $slist[0]['num'];

                        $arr['com'] = $slist[0]['com'];
                        $arr['wname'] = $slist[0]['name'];
                        $arr['type'] = $_GET['type'];
                        $arr['unit'] = $slist[0]['unit'];
                        $arr['wid'] = $slist[0]['id'];
                        $arr['x_type'] = $slist[0]['x_type'];
                        // dump($arr['unit']);
                        // exit;
                        $arr['number'] = $slist[0]['number'];
                        $arr['zong'] = $slist[0]['unit'] * $_GET['num'] ;
                        $arr['ment'] = $m_list[0]['post'];
                        $arr['uname'] = $dada[0]['user'];
                        $arr['time'] = date('Y-m-d');
                        $arr['look'] = '8';  
                        if (M('look')->add($arr) > 0) {
                            $llist = M('look')->where(['uname'=>$arr['uname']])->order('id desc')->limit(1)->select();
                            $date['zname'] = $dada[0]['user'];
                            $date['ztype'] = $dada[0]['m_type'];
                            $date['type'] = $_GET['type'];
                            $date['stype'] = 1;
                            $date['ztime'] = date('Y-m-d');
                            $date['sid'] = $llist[0]['id'];
                            

                           if ($_GET['type'] == '0') {
                           		if (M('sh')->add($date) > 0) {
	                                echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
									exit;
	                            } 
                           }else{
                           		if (M('yue')->add($date) > 0) {
	                                echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
									exit;
	                            } 
                           }

                        }else{
                            echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
							exit;
                        }



                    }else{
                        if ($m_list[0]['post'] == '采购中心') {

                            
                            $arr['num'] = $_GET['num'];
                            $arr['com'] = $slist[0]['com'];
                            $arr['wname'] = $slist[0]['name'];
                            $arr['type'] = $_GET['type'];
                            $arr['unit'] = $slist[0]['unit'];
                            $arr['wid'] = $slist[0]['id'];
                            $arr['x_type'] = $slist[0]['x_type'];
                            // dump($arr['unit']);
                            // exit;
                            $arr['number'] = $slist[0]['number'];
                            $arr['zong'] = $slist[0]['unit'] * $_GET['num'] ;
                            $arr['ment'] = $m_list[0]['post'];
                            $arr['uname'] = $dada[0]['user'];
                            $arr['time'] = date('Y-m-d');
                            $arr['look'] = '9';

                            if (M('look')->add($arr) > 0) {
                                $llist = M('look')->where(['uname'=>$arr['uname']])->order('id desc')->limit(1)->select();
                            //      dump($llist);
                            // exit;
                                $date['zname'] = $dada[0]['user'];
                                $date['ztype'] = $dada[0]['m_type'];
                                $date['stype'] = 1;
                                $date['ztime'] = date('Y-m-d');
                                $date['sid'] = $llist[0]['id'];
                              

                               if ($_GET['type'] == '0') {
	                           		if (M('sh')->add($date) > 0) {
		                                echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
										exit;
		                            } 
	                           }else{
	                           		if (M('yue')->add($date) > 0) {
		                                echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
										exit;
		                            } 
	                           }

                            }else{
                                echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
								exit;
                            }


                          
                        }else{
                            if ($m_list[0]['post'] == '财务中心') {
                                
                                 $arr['num'] = $_GET['num'];
                                $arr['com'] = $slist[0]['com'];
                                $arr['wname'] = $slist[0]['name'];
                                $arr['type'] = $_GET['type'];
                                $arr['unit'] = $slist[0]['unit'];
                                $arr['wid'] = $slist[0]['id'];
                                $arr['x_type'] = $slist[0]['x_type'];
                                // dump($arr['unit']);
                                // exit;
                                $arr['number'] = $slist[0]['number'];
                                $arr['zong'] = $slist[0]['unit'] * $_GET['num'] ;
                                $arr['ment'] = $m_list[0]['post'];
                                $arr['uname'] = $dada[0]['user'];
                                $arr['time'] = date('Y-m-d'); 
                                $arr['look'] = '10'; 
                                if (M('look')->add($arr) > 0) {
                                    $llist = M('look')->where(['uname'=>$arr['uname']])->order('id desc')->limit(1)->select();
                                    $date['zname'] = $dada[0]['user'];
                                    $date['ztype'] = $dada[0]['m_type'];
                                    $date['stype'] = 1;
                                    $date['ztime'] = date('Y-m-d');
                                    $date['sid'] = $llist[0]['id'];
                                  

                                   	if ($_GET['type'] == '0') {
		                           		if (M('sh')->add($date) > 0) {
			                                echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
											exit;
			                            } 
		                           }else{
		                           		if (M('yue')->add($date) > 0) {
			                                echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
											exit;
			                            } 
		                           }
                                }else{
                                    echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
									exit;
                                }
                            }else{
                              // echo '12';
                              // exit;
                                
                                    $arr['num'] = $_GET['num'];
                                    $arr['com'] = $slist[0]['com'];
                                    $arr['wname'] = $slist[0]['name'];
                                    $arr['type'] = $_GET['type'];
                                    $arr['unit'] = $slist[0]['unit'];
                                    $arr['wid'] = $slist[0]['id'];
                                    $arr['x_type'] = $slist[0]['x_type'];
                                    // dump($arr['unit']);
                                    // exit;
                                    $arr['number'] = $slist[0]['number'];
                                    $arr['zong'] = $slist[0]['unit'] * $_GET['num'] ;
                                    $arr['ment'] = $m_list[0]['post'];
                                    $arr['uname'] = $dada[0]['user'];
                                    $arr['time'] = date('Y-m-d'); 
                                    $arr['look'] = '1';  
                                if (M('look')->add($arr) > 0) {
                                    $llist = M('look')->where(['uname'=>$arr['uname']])->order('id desc')->limit(1)->select();
                                    $date['zname'] = $dada[0]['user'];
                                    $date['ztype'] = $dada[0]['m_type'];
                                    $date['stype'] = 1;
                                    $date['ztime'] = date('Y-m-d');
                                    $date['sid'] = $llist[0]['id'];
                                  

                                   if ($_GET['type'] == '0') {
		                           		if (M('sh')->add($date) > 0) {
			                                echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
											exit;
			                            } 
		                           }else{
		                           		if (M('yue')->add($date) > 0) {
			                                echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
											exit;
			                            } 
		                           }
                                }else{
                                    echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
									exit;
                                }
                            }
                        }
                    }
                break;
              case '3':  //经理
                  // echo '111';
                  // exit;
                    $arr['num'] = $_GET['num'];
                    $arr['com'] = $slist[0]['com'];
                    $arr['wname'] = $slist[0]['name'];
                    $arr['type'] = $_GET['type'];
                    $arr['unit'] = $slist[0]['unit'];
                    $arr['wid'] = $slist[0]['id'];
                    $arr['x_type'] = $slist[0]['x_type'];
                                    // dump($arr['unit']);
                                    // exit;
                    $arr['number'] = $slist[0]['number'];
                    $arr['zong'] = $slist[0]['unit'] * $_GET['num'] ;
                    $arr['ment'] = $m_list[0]['post'];
                    $arr['uname'] = $dada[0]['user'];
                    $arr['time'] = date('Y-m-d'); 
                   
                    $arr['look'] = '2';
                  if (M('look')->add($arr) > 0) {
                      $llist = M('look')->where(['uname'=>$arr['uname']])->order('id desc')->limit(1)->select();
                      $date['jname'] = $dada[0]['user'];
                      $date['jtype'] = $dada[0]['m_type'];
                      $date['stype'] = 1;
                      $date['jtime'] = date('Y-m-d');
                      $date['sid'] = $llist[0]['id'];
                  

                      if ($_GET['type'] == '0') {
	                   		if (M('sh')->add($date) > 0) {
	                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
								exit;
	                        } 
	                   }else{
	                   		if (M('yue')->add($date) > 0) {
	                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
								exit;
	                        } 
	                   }

                  }else{
                      echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                break;
              case '4':  //行政
                  
                    $arr['num'] = $_GET['num'];
                    $arr['com'] = $slist[0]['com'];
                    $arr['wname'] = $slist[0]['name'];
                    $arr['type'] = $_GET['type'];
                    $arr['unit'] = $slist[0]['unit'];
                    $arr['wid'] = $slist[0]['id'];
                    $arr['x_type'] = $slist[0]['x_type'];
                                   
                    $arr['number'] = $slist[0]['number'];
                    $arr['zong'] = $slist[0]['unit'] * $_GET['num'] ;
                    $arr['ment'] = $m_list[0]['post'];
                    $arr['uname'] = $dada[0]['user'];
                    $arr['time'] = date('Y-m-d');    
                    $arr['look'] = '2';
                     // dump($arr);
                     //                exit;
                  if (M('look')->add($arr) > 0) {
                      $llist = M('look')->where(['uname'=>$arr['uname']])->order('id desc')->limit(1)->select();
                      $date['zname'] = $dada[0]['user'];
                      $date['ztype'] = $dada[0]['m_type'];
                      $date['stype'] = 1;
                      $date['ztime'] = date('Y-m-d');
                      $date['sid'] = $llist[0]['id'];
                      $date['jname'] = $dada[0]['user'];
                      $date['jtype'] = $dada[0]['m_type'];
                      $date['jtime'] = date('Y-m-d');
         

                      if ($_GET['type'] == '0') {
	                   		if (M('sh')->add($date) > 0) {
	                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
								exit;
	                        } 
	                   }else{
	                   		if (M('yue')->add($date) > 0) {
	                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
								exit;
	                        } 
	                   }

                  }else{
                      echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                break;
              case '5':   //财务
                   
                   $arr['num'] = $_GET['num'];
                    $arr['com'] = $slist[0]['com'];
                    $arr['wname'] = $slist[0]['name'];
                    $arr['type'] = $_GET['type'];
                    $arr['unit'] = $slist[0]['unit'];
                    $arr['wid'] = $slist[0]['id'];
                    $arr['x_type'] = $slist[0]['x_type'];
                                    // dump($arr['unit']);
                                    // exit;
                    $arr['number'] = $slist[0]['number'];
                    $arr['zong'] = $slist[0]['unit'] * $_GET['num'] ;
                    $arr['ment'] = $m_list[0]['post'];
                    $arr['uname'] = $dada[0]['user'];
                    $arr['time'] = date('Y-m-d');    
                    $arr['look'] = '10'; 
                  if (M('look')->add($arr) > 0) {
                      $llist = M('look')->where(['uname'=>$arr['uname']])->order('id desc')->limit(1)->select();
                      $date['zname'] = $dada[0]['user'];
                      $date['ztype'] = $dada[0]['m_type'];
                      $date['stype'] = 1;
                      $date['ztime'] = date('Y-m-d');
                      $date['sid'] = $llist[0]['id'];
                
                      if ($_GET['type'] == '0') {
	                   		if (M('sh')->add($date) > 0) {
	                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
								exit;
	                        } 
	                   }else{
	                   		if (M('yue')->add($date) > 0) {
	                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
								exit;
	                        } 
	                   }

                  }else{
                      echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                break;
              case '8':   //职能总
                  
                    $arr['num'] = $_GET['num'];
                    $arr['com'] = $slist[0]['com'];
                    $arr['wname'] = $slist[0]['name'];
                    $arr['type'] = $_GET['type'];
                    $arr['unit'] = $slist[0]['unit'];
                    $arr['wid'] = $slist[0]['id'];
                    $arr['x_type'] = $slist[0]['x_type'];
                                    // dump($arr['unit']);
                                    // exit;
                    $arr['number'] = $slist[0]['number'];
                    $arr['zong'] = $slist[0]['unit'] * $_GET['num'] ;
                    $arr['ment'] = $m_list[0]['post'];
                    $arr['uname'] = $dada[0]['user'];
                    $arr['time'] = date('Y-m-d');   
                    $arr['look'] = '2'; 
                  if (M('look')->add($arr) > 0) {
                      $llist = M('look')->where(['uname'=>$arr['uname']])->order('id desc')->limit(1)->select();
                      $date['jname'] = $dada[0]['user'];
                      $date['jtype'] = $dada[0]['m_type'];
                      $date['stype'] = 1;
                      $date['jtime'] = date('Y-m-d');
                      $date['sid'] = $llist[0]['id'];
              

                      if ($_GET['type'] == '0') {
	                   		if (M('sh')->add($date) > 0) {
	                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
								exit;
	                        } 
	                   }else{
	                   		if (M('yue')->add($date) > 0) {
	                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
								exit;
	                        } 
	                   }
                  }else{
                      echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                break;
              case '9':   //网络总
                  
                    $arr['num'] = $_GET['num'];
                    $arr['com'] = $slist[0]['com'];
                    $arr['wname'] = $slist[0]['name'];
                    $arr['type'] = $_GET['type'];
                    $arr['unit'] = $slist[0]['unit'];
                    $arr['wid'] = $slist[0]['id'];
                    $arr['x_type'] = $slist[0]['x_type'];
                                    // dump($arr['unit']);
                                    // exit;
                    $arr['number'] = $slist[0]['number'];
                    $arr['zong'] = $slist[0]['unit'] * $_GET['num'] ;
                    $arr['ment'] = $m_list[0]['post'];
                    $arr['uname'] = $dada[0]['user'];
                    $arr['time'] = date('Y-m-d');   
                    $arr['look'] = '2'; 
                  if (M('look')->add($arr) > 0) {
                      $llist = M('look')->where(['uname'=>$arr['uname']])->order('id desc')->limit(1)->select();
                      $date['jname'] = $dada[0]['user'];
                      $date['jtype'] = $dada[0]['m_type'];
                      $date['stype'] = 1;
                      $date['jtime'] = date('Y-m-d');
                      $date['sid'] = $llist[0]['id'];
            

                      if ($_GET['type'] == '0') {
	                   		if (M('sh')->add($date) > 0) {
	                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
								exit;
	                        } 
	                   }else{
	                   		if (M('yue')->add($date) > 0) {
	                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
								exit;
	                        } 
	                   }

                  }else{
                      echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                break;
            case '0':
                    $arr['num'] = $_GET['num'];
                    $arr['com'] = $slist[0]['com'];
                    $arr['wname'] = $slist[0]['name'];
                    $arr['type'] = $_GET['type'];
                    $arr['unit'] = $slist[0]['unit'];
                    $arr['wid'] = $slist[0]['id'];
                    $arr['x_type'] = $slist[0]['x_type'];
                                    // dump($arr['unit']);
                                    // exit;
                    $arr['number'] = $slist[0]['number'];
                    $arr['zong'] = $slist[0]['unit'] * $_GET['num'] ;
                    $arr['ment'] = $m_list[0]['post'];
                    $arr['uname'] = $dada[0]['user'];
                    $arr['time'] = date('Y-m-d'); 
                  // dump($list);
                  // exit;
                 if (M('look')->add($arr) > 0) {
                      echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
							exit;
                  }else{
                      echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                break;
	}

}





	/**
	 * [jadd 急性物品申请]
	 * @return [type] [description]
	 */
	public function jadd()
	{
		$dada = M('member')->where(array('uid'=>$_GET['uid']))->select();
        $z_id = M('auth_group_access')->where(array('uid'=>$_GET['uid']))->select();
                
        $b_id = $z_id[0]['group_id'];
        $m_list = M('auth_group')->where(array('id'=>$b_id))->select();
        // $slist = M('stock')->where(['id'=>$_POST['id']])->select();
        $result[] = $_GET;
       
        
        // dump($list);
        // exit;
        // foreach ($list as $k => $v ){
        //    foreach ($v as $key => $value){
        //        if (!$value){
        //            unset($list[$k][$key]);
        //            continue;
        //        }
        //    }
           
        // }
        //   $result = array_filter($list);
          // dump($result);
          // exit;
          switch ($dada[0]['m_type']) {
              case '2':  //主管
                    // dump($_POST);
                    // exit;
                    if ($m_list[0]['post'] == '行政中心') {
                        
                       foreach ($result as  $value) {
                                   
                                    $value['time'] = date('Y-m-d');
                                    $value['ment'] = $m_list[0]['post'];
                                    $value['type'] = 1;
                                    $value['uname'] = $dada[0]['user'];
                                    $value['look'] = 8;
                                    $r[] = $value;              
                                  }
                                  $count = count($r);
                                if (M('look')->addALL($r) > 0) {
                                    $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                                   foreach ($llist as  $v) {
                                      // dump($v);
                                      $date['zname'] = $dada[0]['user'];
                                      $date['ztype'] = $dada[0]['m_type'];
                                      $date['stype'] = 1;
                                      $date['ztime'] = date('Y-m-d');
                                      $date['sid'] = $v['id'];
                                      $date['wtype'] = '急性物品申购';
                                      // dump($date);
                                      $d[] = $date;
                                    }
                                    
                                    // exit;
                                   if (M('sh')->addALL($d) > 0) {
                                        echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
										exit;
                                    } 

                                }else{
                                   	echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
									exit;
                                }



                    }else{
                        if ($m_list[0]['post'] == '采购中心') {

                            
                           foreach ($result as  $value) {
                 
                                    $value['time'] = date('Y-m-d');
                                    $value['ment'] = $m_list[0]['post'];
                                    $value['type'] = 1;
                                    $value['uname'] = $dada[0]['user'];
                                    $value['look'] = 9;
                                    $r[] = $value;      
                                  }
                                  $count = count($r);
                                if (M('look')->addALL($r) > 0) {
                                    $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                                    foreach ($llist as  $v) {
                                      // dump($v);
                                      $date['zname'] = $dada[0]['user'];
                                      $date['ztype'] = $dada[0]['m_type'];
                                      $date['stype'] = 1;
                                      $date['ztime'] = date('Y-m-d');
                                      $date['sid'] = $v['id'];
                                      $date['wtype'] = '急性物品申购';
                                      // dump($date);
                                      $d[] = $date;
                                    }
                                    
                                    // exit;
                                   if (M('sh')->addALL($d) > 0) {
                                        echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
										exit;
                                    } 

                                }else{
                                   echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
									exit;
                                }


                          
                        }else{
                            if ($m_list[0]['post'] == '财务中心') {
                                
                                foreach ($result as  $value) {
                                    $value['time'] = date('Y-m-d');
                                    $value['ment'] = $m_list[0]['post'];
                                    $value['type'] = 1;
                                    $value['uname'] = $dada[0]['user'];
                                    $value['look'] = 10;
                                    $r[] = $value;                         
                                  }
                                  $count = count($r);
                                if (M('look')->addALL($r) > 0) {
                                    $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                                    foreach ($llist as  $v) {
                                      // dump($v);
                                      $date['zname'] = $dada[0]['user'];
                                      $date['ztype'] = $dada[0]['m_type'];
                                      $date['stype'] = 1;
                                      $date['ztime'] = date('Y-m-d');
                                      $date['sid'] = $v['id'];
                                      $date['wtype'] = '急性物品申购';
                                      // dump($date);
                                      $d[] = $date;
                                    }
                                    
                                    // exit;
                                   if (M('sh')->addALL($d) > 0) {
                                        echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
										exit;
                                    } 

                                }else{
                                   	echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
									exit;
                                }
                            }else{
                              // echo '12';
                              // exit;
                                
                                  foreach ($result as  $value) {
                                   
                                  
                                   
                                    $value['time'] = date('Y-m-d');
                                    $value['ment'] = $m_list[0]['post'];
                                    $value['type'] = 1;
                                    $value['uname'] = $dada[0]['user'];
                                    $value['look'] = 1;
                                    $r[] = $value;                       
                                  }

                                    // echo  M("look")->fetchSql()->addALL($r);
                                    // exit;
                                    // foreach ($r as $valu) {
                                    //     if (!empty($valu)) {
                                    //         $e[] = $valu;
                                    //     }
                                    
                                    // // }
                                    $count = count($r);
                                    // dump($r);
                                    // exit;
                                if (M('look')->addALL($r) > 0) {
                                    $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                                    // dump($llist);
                                    // exit;
                                    foreach ($llist as  $v) {
                                      // dump($v);
                                      $date['zname'] = $dada[0]['user'];
                                      $date['ztype'] = $dada[0]['m_type'];
                                      $date['stype'] = 1;
                                      $date['ztime'] = date('Y-m-d');
                                      $date['sid'] = $v['id'];
                                      $date['wtype'] = '急性物品申购';
                                      // dump($date);
                                      $d[] = $date;
                                    }
                                  

                                    // exit;
                                   if (M('sh')->addALL($d) > 0) {
                                        echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
										exit;
                                    } 

                                }else{
                                   	echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
									exit;
                                }
                            }
                        }
                    }
                break;
              case '3':  //经理
                  // echo '111';
                  // exit;
                  foreach ($result as  $value) {
                    $value['time'] = date('Y-m-d');
                    $value['ment'] = $m_list[0]['post'];
                    $value['type'] = 1;
                    $value['uname'] = $dada[0]['user'];
                    $value['look'] = 2;
                    $r[] = $value;           
                  }
                  $count = count($r);
                  if (M('look')->addALL($r) > 0) {
                      $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                      foreach ($llist as  $v) {
                        // dump($v);
                        $date['jname'] = $dada[0]['user'];
                        $date['jtype'] = $dada[0]['m_type'];
                        $date['stype'] = 1;
                        $date['jtime'] = date('Y-m-d');
                        $date['sid'] = $v['id'];
                        $date['wtype'] = '急性物品申购';
                        // dump($date);
                        $d[] = $date;
                      }
                                    
                      // exit;
                      if (M('sh')->addALL($d) > 0) {
                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
							exit;
                      } 

                  }else{
                      	echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                 
                break;
              case '4':  //行政
                  
                   foreach ($result as  $value) {
                    $value['time'] = date('Y-m-d');
                    $value['ment'] = $m_list[0]['post'];
                    $value['type'] = 1;
                    $value['uname'] = $dada[0]['user'];
                    $value['look'] = 8;
                    $r[] = $value;                          
                  }
                  $count = count($r);
                  if (M('look')->addALL($r) > 0) {
                      $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                      foreach ($llist as  $v) {
                        // dump($v);
                        $date['zname'] = $dada[0]['user'];
                        $date['ztype'] = $dada[0]['m_type'];
                        $date['stype'] = 1;
                        $date['ztime'] = date('Y-m-d');
                        $date['sid'] = $v['id'];
                        $date['wtype'] = '急性物品申购';
                        // dump($date);
                        $d[] = $date;
                      }
                                    
                      // exit;
                      if (M('sh')->addALL($d) > 0) {
                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
							exit;
                      } 

                  }else{
                      	echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                break;
              case '5':   //财务
                   
                    foreach ($result as  $value) {
                    $value['time'] = date('Y-m-d');
                    $value['ment'] = $m_list[0]['post'];
                    $value['type'] = 1;
                    $value['uname'] = $dada[0]['user'];
                    $value['look'] = 10;
                    $r[] = $value;                          
                  }
                  $count = count($r);
                  if (M('look')->addALL($r) > 0) {
                      $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                      foreach ($llist as  $v) {
                        // dump($v);
                        $date['zname'] = $dada[0]['user'];
                        $date['ztype'] = $dada[0]['m_type'];
                        $date['stype'] = 1;
                        $date['ztime'] = date('Y-m-d');
                        $date['sid'] = $v['id'];
                        $date['wtype'] = '急性物品申购';
                        // dump($date);
                        $d[] = $date;
                      }
                                    
                      // exit;
                      if (M('sh')->addALL($d) > 0) {
                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
							exit;
                      } 

                  }else{
                      	echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                break;
              case '8':   //职能总
                  
                  foreach ($result as  $value) {
                    $value['time'] = date('Y-m-d');
                    $value['ment'] = $m_list[0]['post'];
                    $value['type'] = 1;
                    $value['uname'] = $dada[0]['user'];
                    $value['look'] = 2;
                    $r[] = $value;                          
                  }
                  $count = count($r);
                  if (M('look')->addALL($r) > 0) {
                      $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                      foreach ($llist as  $v) {
                        // dump($v);
                        $date['jname'] = $dada[0]['user'];
                        $date['jtype'] = $dada[0]['m_type'];
                        $date['stype'] = 1;
                        $date['jtime'] = date('Y-m-d');
                        $date['sid'] = $v['id'];
                        $date['wtype'] = '急性物品申购';
                        // dump($date);
                        $d[] = $date;
                      }
                                    
                      // exit;
                      if (M('sh')->addALL($d) > 0) {
                            echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
							exit;
                      } 

                  }else{
                      	echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                break;
              case '9':   //网络总
                  
                  foreach ($result as  $value) {
                    $value['time'] = date('Y-m-d');
                    $value['ment'] = $m_list[0]['post'];
                    $value['type'] = 1;
                    $value['uname'] = $dada[0]['user'];
                    $value['look'] = 2;
                    $r[] = $value;                          
                  }
                  
                  $count = count($r);
                  if (M('look')->addALL($r) > 0) {
                      $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                      foreach ($llist as  $v) {
                        // dump($v);
                        $date['jname'] = $dada[0]['user'];
                        $date['jtype'] = $dada[0]['m_type'];
                        $date['stype'] = 1;
                        $date['jtime'] = date('Y-m-d');
                        $date['sid'] = $v['id'];
                        $date['wtype'] = '急性物品申购';
                        // dump($date);
                        $d[] = $date;
                      }
                                    
                      // exit;
                      if (M('sh')->addALL($d) > 0) {
                           	echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
							exit;
                      } 

                  }else{
                      	echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                break;
            case '0':
            // dump($result);
            // exit;
                  foreach ($result as  $value) {
                    $value['time'] = date('Y-m-d');
                    $value['ment'] = $m_list[0]['post'];
                    $value['type'] = 1;
                    $value['uname'] = $dada[0]['user'];
                    $value['look'] = 0;
                    $r[] = $value;                    
                  }
                  // dump($r);
                  // exit;
                 if (M('look')->addALL($r) > 0) {
                      	echo json_encode(array("status"=>1,'message'=>'申请成功',"data"=>[]));
						exit;
                  }else{
                      	echo json_encode(array("status"=>0,'message'=>'申请失败',"data"=>[]));
						exit;
                  }
                break;
            }
	}



	


	/**
	 * [count 审批分类]
	 * @return [uid] [用户id]
	 */
	public function count()
	{
		$ulist = M('member')->where(['uid'=>$_GET['uid']])->select();
		$gid = M('auth_group_access')->where(['uid'=>$_GET['uid']])->select();
		$glist = M('auth_group')->where(['id'=>$gid[0]['group_id']])->select();
		$apost = $glist[0]['post'];
		
		switch ($ulist[0]['m_type']) {
			case '2':  //主管
				$ffnum = M('cost')->where(['ment'=>$apost,'look'=>0,'ju'=>0])->count();//费用报销
		        $bbnum = M('look')->where(['ment'=>$apost,'look'=>0,'ju'=>0,'type'=>0])->count();//办公用品
		        $yynum = M('look')->where(['ment'=>$apost,'look'=>0,'ju'=>0,'type'=>3])->count();
		        $jjnum = M('look')->where(['ment'=>$apost,'look'=>0,'ju'=>0,'type'=>1])->count();
		        $ggnum = M('look')->where(['ment'=>$apost,'look'=>0,'ju'=>0,'type'=>2])->count();
		        $ccnum = M('turn')->where(['ment'=>$apost,'look'=>0,'ju'=>0])->count();
		        $arr = array(
					"rmb"=> array(
						'type' => 0,
						'count' => $ffnum//费用报销
						),
					"ban"=> array(
						'type' => 1,
						'count' => $bbnum//办公用品
						),
					"yue"=> array(
						'type' => 2,
						'count' => $yynum//月度申请
						),
					"jix"=> array(
						'type' => 3,
						'count' => $jjnum//急性物资
						),
					"gud"=> array(
						'type' => 4,
						'count' => $ggnum//固定资产
						),
					"che"=> array(
						'type' => 5,
						'count' => $ccnum//车辆申请
						)
					
					
				);

				$res = [
					'status' => '1',
					'message' => '请求成功',
					'data'    => array_values($arr)
				];
				// dump($arr);
				// exit;
				// echo 1111;+
				echo json_encode($res);

				// exit;
				break;
			
			case '3':  //经理
				switch ($apost) {
                    case '行政中心':
                            $ffnum = M('cost')->where(['ment'=>$apost,'look'=>8,'ju'=>0])->count();//费用报销
                            $bbnum = M('look')->where(['ment'=>$apost,'look'=>8,'ju'=>0,'type'=>0])->count();//办公用品
                            $yynum = M('look')->where(['ment'=>$apost,'look'=>8,'ju'=>0,'type'=>3])->count();
                            $jjnum = M('look')->where(['ment'=>$apost,'look'=>8,'ju'=>0,'type'=>1])->count();
                            $ggnum = M('look')->where(['ment'=>$apost,'look'=>8,'ju'=>0,'type'=>2])->count();
                            $ccnum = M('turn')->where(['ment'=>$apost,'look'=>8,'ju'=>0])->count();
                            $arr = array(
								"rmb"=> array(
									'type' => 0,
									'count' => $ffnum//费用报销
									),
								"ban"=> array(
									'type' => 1,
									'count' => $bbnum//费用报销
									),
								"yue"=> array(
									'type' => 2,
									'count' => $yynum//费用报销
									),
								"jix"=> array(
									'type' => 3,
									'count' => $jjnum//费用报销
									),
								"gud"=> array(
									'type' => 4,
									'count' => $ggnum//费用报销
									),
								"che"=> array(
									'type' => 5,
									'count' => $ccnum//费用报销
									)
								
								
							);

							$res = [
								'status' => '1',
								'message' => '请求成功',
								'data'    => array_values($arr)
							];
							// dump($arr);
							// exit;
							// echo 1111;+
							echo json_encode($res);

							exit;
                          
                        break;
                    case '财务中心':
                            $ffbnum = M('cost')->where(['ment'=>$apost,'look'=>10,'ju'=>0])->count();//费用报销
                            $ffgnum = M('cost')->where(['look'=>3,'ju'=>0])->count();//费用报销
                            $ffnum = $ffbnum + $ffgnum;
                            $bbnum = M('look')->where(['ment'=>$apost,'look'=>10,'ju'=>0,'type'=>0,'que'=>0])->count();//办公用品
                            $yybnum = M('look')->where(['ment'=>$apost,'look'=>10,'ju'=>0,'type'=>3])->count();
                            $yygnum = M('look')->where(['num'=>array('exp',' >number '),'type'=>3,'look'=>3,'ju'=>0])->count();
                            $yynum = $yybnum + $yygnum;
                            $jjbnum = M('look')->where(['ment'=>$apost,'look'=>10,'ju'=>0,'type'=>1])->count();
                            $jjgnum = M('look')->where(['type'=>1,'look'=>3,'ju'=>0])->count();
                            $jjnum = $jjbnum + $jjgnum;
                            $ggbnum = M('look')->where(['ment'=>$apost,'look'=>10,'ju'=>0,'type'=>2])->count();
                            $gggnum = M('look')->where(['type'=>2,'look'=>3,'ju'=>0])->count();
                            $ggnum = $ggbnum + $gggnum;
                            $ccnum = M('turn')->where(['ment'=>$apost,'look'=>10,'ju'=>0])->count();
                            $arr = array(
								"rmb"=> array(
									'type' => 0,
									'count' => $ffnum//费用报销
									),
								"ban"=> array(
									'type' => 1,
									'count' => $bbnum//费用报销
									),
								"yue"=> array(
									'type' => 2,
									'count' => $yynum//费用报销
									),
								"jix"=> array(
									'type' => 3,
									'count' => $jjnum//费用报销
									),
								"gud"=> array(
									'type' => 4,
									'count' => $ggnum//费用报销
									),
								"che"=> array(
									'type' => 5,
									'count' => $ccnum//费用报销
									)
								
								
							);

							$res = [
								'status' => '1',
								'message' => '请求成功',
								'data'    => array_values($arr)
							];
							// dump($arr);
							// exit;
							// echo 1111;+
							echo json_encode($res);

							exit;
       //                      $array = array(
							// 	"status"=>1,
							// 	'message'=>'请求成功',
							// 	"rmb"=>$ffnum,//费用报销
							// 	"ban"=>$bbnum,//办公用品
							// 	"yue"=>$yynum,//月度需求
							// 	"jix"=>$jjnum,//急性物资
							// 	"gud"=>$ggnum,//固定资产
							// 	"che"=>$ccnum//派车审批
								
							// );
							// echo json_encode($array);
							// exit;
                        break;
                    case '采购中心':
                            $ffnum = M('cost')->where(['ment'=>$apost,'look'=>9,'ju'=>0])->count();//费用报销
                            $bbnum = M('look')->where(['ment'=>$apost,'look'=>9,'ju'=>0,'type'=>0])->count();//办公用品
                            $yynum = M('look')->where(['ment'=>$apost,'look'=>9,'ju'=>0,'type'=>3])->count();
                            $jjnum = M('look')->where(['ment'=>$apost,'look'=>9,'ju'=>0,'type'=>1])->count();
                            $ggnum = M('look')->where(['ment'=>$apost,'look'=>9,'ju'=>0,'type'=>2])->count();
                            $ccnum = M('turn')->where(['ment'=>$apost,'look'=>9,'ju'=>0])->count();
                            $arr = array(
								"rmb"=> array(
									'type' => 0,
									'count' => $ffnum//费用报销
									),
								"ban"=> array(
									'type' => 1,
									'count' => $bbnum//费用报销
									),
								"yue"=> array(
									'type' => 2,
									'count' => $yynum//费用报销
									),
								"jix"=> array(
									'type' => 3,
									'count' => $jjnum//费用报销
									),
								"gud"=> array(
									'type' => 4,
									'count' => $ggnum//费用报销
									),
								"che"=> array(
									'type' => 5,
									'count' => $ccnum//费用报销
									)
								
								
							);

							$res = [
								'status' => '1',
								'message' => '请求成功',
								'data'    => array_values($arr)
							];
							// dump($arr);
							// exit;
							// echo 1111;+
							echo json_encode($res);

							exit;
                        break;
                }
				break;
			case '4'://行政
                // $ffnum = M('cost')->where(['look'=>2,'ju'=>0])->count();//费用报销
                $bbnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>0])->count();//办公用品
                $yynum = M('look')->where(['look'=>2,'ju'=>0,'type'=>3])->count();
                $jjnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>1])->count();
                $ggnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>2])->count();
                $ccnum = M('turn')->where(['look'=>2,'ju'=>0])->count();
                $arr = array(
					// "rmb"=> array(
					// 	'type' => 0,
					// 	'count' => $ffnum//费用报销
					// 	),
					"ban"=> array(
						'type' => 1,
						'count' => $bbnum//费用报销
						),
					"yue"=> array(
						'type' => 2,
						'count' => $yynum//费用报销
						),
					"jix"=> array(
						'type' => 3,
						'count' => $jjnum//费用报销
						),
					"gud"=> array(
						'type' => 4,
						'count' => $ggnum//费用报销
						),
					"che"=> array(
						'type' => 5,
						'count' => $ccnum//费用报销
						)
					
					
				);

				$res = [
					'status' => '1',
					'message' => '请求成功',
					'data'    => array_values($arr)
				];
				// dump($arr);
				// exit;
				// echo 1111;+
				echo json_encode($res);

				exit;
                break;
            case '5'://财务
              	// $ffgnum = M('cost')->where(['look'=>3,'ju'=>0])->count();//费用报销
                $yynum = M('look')->where(['look'=>3,'ju'=>0,'type'=>3])->count();
                $jjnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>1])->count();
                $ggnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>2])->count();
              
               	$arr = array(
					// "rmb"=> array(
					// 	'type' => 0,
					// 	'count' => $ffnum//费用报销
					// 	),
					// "ban"=> array(
					// 	'type' => 1,
					// 	'count' => $bbnum//费用报销
					// 	),
					"yue"=> array(
						'type' => 2,
						'count' => $yynum//费用报销
						),
					"jix"=> array(
						'type' => 3,
						'count' => $jjnum//费用报销
						),
					"gud"=> array(
						'type' => 4,
						'count' => $ggnum//费用报销
						)
					// "che"=> array(
					// 	'type' => 5,
					// 	'count' => $ccnum//费用报销
					// 	)
					
					
				);

				$res = [
					'status' => '1',
					'message' => '请求成功',
					'data'    => array_values($arr)
				];
				// dump($arr);
				// exit;
				// echo 1111;+
				echo json_encode($res);

				exit;
                break;
            case '10'://财务(报销)
                
                $ffnum = M('cost')->where(['look'=>2,'ju'=>0])->count();//费用报销
                $arr = array(
					"rmb"=> array(
						'type' => 0,
						'count' => $ffnum//费用报销
						)
					
					
					
				);

				$res = [
					'status' => '1',
					'message' => '请求成功',
					'data'    => array_values($arr)
				];
				// dump($arr);
				// exit;
				// echo 1111;+
				echo json_encode($res);

				exit;
                break;
		}
	}


	/**
	 * [monthly 月度申请审批列表展示]
	 * @return [uid] [用户id]
	 */
	public function monthly()
	{
		$type = $_GET['type'];
	    $gid = M('auth_group_access')->where(['uid'=>$_GET['uid']])->find();
	    $glist = M('auth_group')->where(['id'=>$gid['group_id']])->find();
	    $ulist = M('member')->where(['uid'=>$_GET['uid']])->find();
	    $apost = $glist['post'];
	    $page = isset($_GET['page'])?$_GET['page']:1;
	        switch ($ulist['m_type']) {
	          case '2':   //主管
	          		switch ($type) {
	          			case '0':
	          				//查询总条数
							$count = M('look')->where(['type'=>3,'look'=>0,'ment'=>$apost,'ju'=>0])->count();
							if ($count == '0') {
								$count = 1;
							}
							//每页显示数
							$pageSize = 20;
							//计算总页数
							$a = ceil($count / $pageSize);
							if ($page > $a) {
								// $page = $a;
								echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
								exit;
							}

							//sql查询起始位置
							$start = ($page - 1) * $pageSize;
							// echo $start;
							// exit;
							//得到数据
							$list = M('look')->where(['type'=>3,'look'=>0,'ment'=>$apost,'ju'=>0])->order("id asc")->limit("$start,$pageSize")->select();
							
							if (!empty($list)) {
								$arr = [];
								foreach ($list as $key => $value) {
									$value['jname'] = '';
									$value['jcent'] = '';
									$arr[] = $value;
								}
								// dump($arr);
								// exit;
								$array = array(
									"status"=>1,
									'message'=>'请求成功',
									"count"=>$count,//总条数
									"pageSize"=>$pageSize, //每页显示条数
									"thisPage"=>$page, //当前页码
									"type"=> '0', //待审批
									"data"=>$arr//列表
									);
								echo json_encode($array);
								exit;
							}else{
								echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
								exit;
							}
	          				break;
	          			case '1':
	          				// echo $type;
	          				// exit;
	          				//查询总条数
							$count = M('look')->where(['type'=>3,'look'=>1,'ment'=>$apost,'ju'=>0])->count();
							// dump($count);
							// exit;
							//每页显示数
							$pageSize = 20;
							if ($count == '0') {
								$count = 1;
							}
							//计算总页数
							$a = ceil($count / $pageSize);

							if ($page > $a) {
								echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
								exit;
							}
							
							//sql查询起始位置
							$start = ($page - 1) * $pageSize;
							// echo $start;
							// exit;
							//得到数据
							$list = M('look')->where(['type'=>3,'look'=>1,'ment'=>$apost,'ju'=>0])->order("id asc")->limit("$start,$pageSize")->select();
							// dump($list);
							// exit;
							if (!empty($list)) {
								$arr = [];
								foreach ($list as $key => $value) {
									$value['jname'] = '';
									$value['jcent'] = '';
									$arr[] = $value;
								}
								$array = array(
									"status"=>1,
									'message'=>'请求成功',
									"count"=>$count,//总条数
									"pageSize"=>$pageSize, //每页显示条数
									"thisPage"=>$page, //当前页码.
									"type"=> '1', //已通过.
									"data"=>$arr//列表
									);
								echo json_encode($array);
								exit;
							}else{
								echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
								exit;
							}
	          				break;
	          			case '2':
	          				//查询总条数
							$count = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['neq',0],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0])->count();
							// dump($count);
							// exit;
							if ($count == '0') {
								$count = 1;
							}
							// echo $count;
							// exit;
							//每页显示数
							$pageSize = 20;
							//计算总页数
							$a = ceil($count / $pageSize);
							
							if ($page > $a) {
								// $page = $a;
								echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
								exit;
							}

							//sql查询起始位置
							$start = ($page - 1) * $pageSize;
							// echo $start;
							// exit;
							//得到数据
							$list = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['neq',0],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0])->order("time asc")->limit("$start,$pageSize")->select();
							$arr = [];
							foreach ($list as $key => $value) {
								if ($value != '') {
									// unset($list[$key]);
									$arr[] = array_filter($value);
								}
							}
							$arrlist = [];
							foreach ($arr as $key => $value) {
								if ($value['ju'] == '1') {
									$value['jname'] = $value['zname'];
									$value['jtime'] = $value['ztime'];
									$value['jtype'] = $value['ztype'];
									unset($value['zname']);
									unset($value['ztime']);
									unset($value['ztype']);
								}
								if ($value['ju'] == '3') {
									$value['jname'] = $value['xname'];
									$value['jtime'] = $value['xtime'];
									$value['jtype'] = $value['xtype'];
									unset($value['xname']);
									unset($value['xtime']);
									unset($value['xtype']);
								}
								if ($value['ju'] == '4') {
									$value['jname'] = $value['cname'];
									$value['jtime'] = $value['ctime'];
									$value['jtype'] = $value['ctype'];
									unset($value['cname']);
									unset($value['ctime']);
									unset($value['ctype']);
								}
								if ($value['ju'] == '5') {
									$value['jname'] = $value['gname'];
									$value['jtime'] = $value['gtime'];
									$value['jtype'] = $value['gtype'];
									unset($value['gname']);
									unset($value['gtime']);
									unset($value['gtype']);
								}
								if ($value['ju'] == '6') {
									$value['jname'] = $value['dname'];
									$value['jtime'] = $value['dtime'];
									$value['jtype'] = $value['dtype'];
									unset($value['dname']);
									unset($value['dtime']);
									unset($value['dtype']);
								}
								$arrlist[] = $value;
							}
							// echo '11';
							// exit;
							// $listarr = array_filter($list);
							// dump($arrlist);
							// exit;
							if (!empty($arrlist)) {
								
								$array = array(
									"status"=>1,
									'message'=>'请求成功',
									"count"=>$count,//总条数
									"pageSize"=>$pageSize, //每页显示条数
									"thisPage"=>$page, //当前页码
									"type"=> '2', //已拒绝
									"data"=>$arrlist//列表
									);
								echo json_encode($array);
								exit;
							}else{
								echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
								exit;
							}
	          				break;				
	          			
	          		}
	              
	            break;
	          case '3':   //经理
	              switch ($apost) {
	                case '行政中心':
	                   	switch ($type) {
		          			case '0':
		          				//查询总条数
								$count = M('look')->where(['type'=>3,'look'=>8,'ment'=>$apost,'ju'=>0])->count();
								if ($count == '0') {
									$count = 1;
								}
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(['type'=>3,'look'=>8,'ment'=>$apost,'ju'=>0])->order("id asc")->limit("$start,$pageSize")->select();
								
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									// dump($arr);
									// exit;
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '0', //待审批
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
									exit;
								}
		          				break;
		          			case '1':
		          				// echo $type;
		          				// exit;
		          				//查询总条数
								$count = M('look')->where(['type'=>3,'look'=>2,'ment'=>$apost,'ju'=>0])->count();
								// dump($count);
								// exit;
								//每页显示数
								$pageSize = 20;
								if ($count == '0') {
									$count = 1;
								}
								//计算总页数
								$a = ceil($count / $pageSize);

								if ($page > $a) {
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
								
								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(['type'=>3,'look'=>2,'ment'=>$apost,'ju'=>0])->order("id asc")->limit("$start,$pageSize")->select();
								// dump($list);
								// exit;
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码.
										"type"=> '1', //已通过.
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;
		          			case '2':
		          				//查询总条数
								$count = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0])->count();
								// dump($count);
								// exit;
								if ($count == '0') {
									$count = 1;
								}
								// echo $count;
								// exit;
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0])->order("time asc")->limit("$start,$pageSize")->select();
								$arr = [];
								foreach ($list as $key => $value) {
									if ($value != '') {
										// unset($list[$key]);
										$arr[] = array_filter($value);
									}
								}
								$arrlist = [];
								foreach ($arr as $key => $value) {
									if ($value['ju'] == '1') {
										$value['jname'] = $value['zname'];
										$value['jtime'] = $value['ztime'];
										$value['jtype'] = $value['ztype'];
										unset($value['zname']);
										unset($value['ztime']);
										unset($value['ztype']);
									}
									if ($value['ju'] == '3') {
										$value['jname'] = $value['xname'];
										$value['jtime'] = $value['xtime'];
										$value['jtype'] = $value['xtype'];
										unset($value['xname']);
										unset($value['xtime']);
										unset($value['xtype']);
									}
									if ($value['ju'] == '4') {
										$value['jname'] = $value['cname'];
										$value['jtime'] = $value['ctime'];
										$value['jtype'] = $value['ctype'];
										unset($value['cname']);
										unset($value['ctime']);
										unset($value['ctype']);
									}
									if ($value['ju'] == '5') {
										$value['jname'] = $value['gname'];
										$value['jtime'] = $value['gtime'];
										$value['jtype'] = $value['gtype'];
										unset($value['gname']);
										unset($value['gtime']);
										unset($value['gtype']);
									}
									if ($value['ju'] == '6') {
										$value['jname'] = $value['dname'];
										$value['jtime'] = $value['dtime'];
										$value['jtype'] = $value['dtype'];
										unset($value['dname']);
										unset($value['dtime']);
										unset($value['dtype']);
									}
									$arrlist[] = $value;
								}
								// echo '11';
								// exit;
								// $listarr = array_filter($list);
								// dump($arrlist);
								// exit;
								if (!empty($arrlist)) {
									
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '2', //已拒绝
										"data"=>$arrlist//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;				
		          			
		          		}
	                  break;

	                case '采购中心':
	                	switch ($type) {
		          			case '0':
		          				//查询总条数
								$count = M('look')->where(['type'=>3,'look'=>9,'ment'=>$apost,'ju'=>0])->count();
								if ($count == '0') {
									$count = 1;
								}
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(['type'=>3,'look'=>9,'ment'=>$apost,'ju'=>0])->order("id asc")->limit("$start,$pageSize")->select();
								
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									// dump($arr);
									// exit;
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '0', //待审批
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
									exit;
								}
		          				break;
		          			case '1':
		          				// echo $type;
		          				// exit;
		          				//查询总条数
								$count = M('look')->where(['type'=>3,'look'=>2,'ment'=>$apost,'ju'=>0])->count();
								// dump($count);
								// exit;
								//每页显示数
								$pageSize = 20;
								if ($count == '0') {
									$count = 1;
								}
								//计算总页数
								$a = ceil($count / $pageSize);

								if ($page > $a) {
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
								
								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(['type'=>3,'look'=>2,'ment'=>$apost,'ju'=>0])->order("id asc")->limit("$start,$pageSize")->select();
								// dump($list);
								// exit;
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码.
										"type"=> '1', //已通过.
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;
		          			case '2':
		          				//查询总条数
								$count = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0])->count();
								// dump($count);
								// exit;
								if ($count == '0') {
									$count = 1;
								}
								// echo $count;
								// exit;
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0])->order("time asc")->limit("$start,$pageSize")->select();
								$arr = [];
								foreach ($list as $key => $value) {
									if ($value != '') {
										// unset($list[$key]);
										$arr[] = array_filter($value);
									}
								}
								$arrlist = [];
								foreach ($arr as $key => $value) {
									if ($value['ju'] == '1') {
										$value['jname'] = $value['zname'];
										$value['jtime'] = $value['ztime'];
										$value['jtype'] = $value['ztype'];
										unset($value['zname']);
										unset($value['ztime']);
										unset($value['ztype']);
									}
									if ($value['ju'] == '3') {
										$value['jname'] = $value['xname'];
										$value['jtime'] = $value['xtime'];
										$value['jtype'] = $value['xtype'];
										unset($value['xname']);
										unset($value['xtime']);
										unset($value['xtype']);
									}
									if ($value['ju'] == '4') {
										$value['jname'] = $value['cname'];
										$value['jtime'] = $value['ctime'];
										$value['jtype'] = $value['ctype'];
										unset($value['cname']);
										unset($value['ctime']);
										unset($value['ctype']);
									}
									if ($value['ju'] == '5') {
										$value['jname'] = $value['gname'];
										$value['jtime'] = $value['gtime'];
										$value['jtype'] = $value['gtype'];
										unset($value['gname']);
										unset($value['gtime']);
										unset($value['gtype']);
									}
									if ($value['ju'] == '6') {
										$value['jname'] = $value['dname'];
										$value['jtime'] = $value['dtime'];
										$value['jtype'] = $value['dtype'];
										unset($value['dname']);
										unset($value['dtime']);
										unset($value['dtype']);
									}
									$arrlist[] = $value;
								}
								// echo '11';
								// exit;
								// $listarr = array_filter($list);
								// dump($arrlist);
								// exit;
								if (!empty($arrlist)) {
									
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '2', //已拒绝
										"data"=>$arrlist//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;				
		          			
		          		}
	                   
	                  break;
	                case '财务中心':
	                	switch ($type) {
		          			case '0':
		          				//查询总条数
								$count = M('look')->where(['type'=>3,'look'=>10,'ment'=>$apost,'ju'=>0])->count();
								if ($count == '0') {
									$count = 1;
								}
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(['type'=>3,'look'=>10,'ment'=>$apost,'ju'=>0])->order("id asc")->limit("$start,$pageSize")->select();
								
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									// dump($arr);
									// exit;
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '0', //待审批
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
									exit;
								}
		          				break;
		          			case '1':
		          				// echo $type;
		          				// exit;
		          				//查询总条数
								$count = M('look')->where(['type'=>3,'look'=>2,'ment'=>$apost,'ju'=>0])->count();
								// dump($count);
								// exit;
								//每页显示数
								$pageSize = 20;
								if ($count == '0') {
									$count = 1;
								}
								//计算总页数
								$a = ceil($count / $pageSize);

								if ($page > $a) {
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
								
								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(['type'=>3,'look'=>2,'ment'=>$apost,'ju'=>0])->order("id asc")->limit("$start,$pageSize")->select();
								// dump($list);
								// exit;
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码.
										"type"=> '1', //已通过.
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;
		          			case '2':
		          				//查询总条数
								$count = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0])->count();
								// dump($count);
								// exit;
								if ($count == '0') {
									$count = 1;
								}
								// echo $count;
								// exit;
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0])->order("time asc")->limit("$start,$pageSize")->select();
								$arr = [];
								foreach ($list as $key => $value) {
									if ($value != '') {
										// unset($list[$key]);
										$arr[] = array_filter($value);
									}
								}
								$arrlist = [];
								foreach ($arr as $key => $value) {
									if ($value['ju'] == '1') {
										$value['jname'] = $value['zname'];
										$value['jtime'] = $value['ztime'];
										$value['jtype'] = $value['ztype'];
										unset($value['zname']);
										unset($value['ztime']);
										unset($value['ztype']);
									}
									if ($value['ju'] == '3') {
										$value['jname'] = $value['xname'];
										$value['jtime'] = $value['xtime'];
										$value['jtype'] = $value['xtype'];
										unset($value['xname']);
										unset($value['xtime']);
										unset($value['xtype']);
									}
									if ($value['ju'] == '4') {
										$value['jname'] = $value['cname'];
										$value['jtime'] = $value['ctime'];
										$value['jtype'] = $value['ctype'];
										unset($value['cname']);
										unset($value['ctime']);
										unset($value['ctype']);
									}
									if ($value['ju'] == '5') {
										$value['jname'] = $value['gname'];
										$value['jtime'] = $value['gtime'];
										$value['jtype'] = $value['gtype'];
										unset($value['gname']);
										unset($value['gtime']);
										unset($value['gtype']);
									}
									if ($value['ju'] == '6') {
										$value['jname'] = $value['dname'];
										$value['jtime'] = $value['dtime'];
										$value['jtype'] = $value['dtype'];
										unset($value['dname']);
										unset($value['dtime']);
										unset($value['dtype']);
									}
									$arrlist[] = $value;
								}
								// echo '11';
								// exit;
								// $listarr = array_filter($list);
								// dump($arrlist);
								// exit;
								if (!empty($arrlist)) {
									
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '2', //已拒绝
										"data"=>$arrlist//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;				
		          			
		          		}
	                   
	                  break;
	                
	                
	              }
	            break;
	          case '4':  //行政
	    //       		//查询总条数
					// $count = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>2,'ju'=>0))->count();
					// //每页显示数
					// $pageSize = 20;
					// //计算总页数
					// $a = ceil($count / $pageSize);
					// if ($page > $a) {
					// 	$page = $a;
					// }
					// //sql查询起始位置
					// $start = ($page - 1) * $pageSize;
					// //得到数据
					// $list = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>2,'ju'=>0))->order("id asc")->limit("$start,$pageSize")->select();
					// $ylist = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>2,'ju'=>0))->select();
	    //           	foreach ($ylist as  $v) {
	    //             	$coun += $v['zong']; 
	    //           	}
					// if (!empty($list)) {
						
					// 	$array = array(
					// 		"status"=>1,
					// 		'message'=>'请求成功',
					// 		"count"=>$count,//总条数
					// 		"pageSize"=>$pageSize, //每页显示条数
					// 		"thisPage"=>$page, //当前页码
					// 		"data"=>$list,//列表
					// 		"coun"=>$coun//总和
					// 		);
					// 	echo json_encode($array);
					// 	exit;
					// }else{
					// 	echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
					// 	exit;
					// }
					switch ($type) {
		          			case '0':
		          				//查询总条数
								$count = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>2,'ju'=>0))->count();
								if ($count == '0') {
									$count = 1;
								}
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>2,'ju'=>0))->order("id asc")->limit("$start,$pageSize")->select();
								
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									// dump($arr);
									// exit;
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '0', //待审批
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
									exit;
								}
		          				break;
		          			case '1':
		          				// echo $type;
		          				// exit;
		          				//查询总条数
								$count = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>3,'ju'=>0))->count();
								// dump($count);
								// exit;
								//每页显示数
								$pageSize = 20;
								if ($count == '0') {
									$count = 1;
								}
								//计算总页数
								$a = ceil($count / $pageSize);

								if ($page > $a) {
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
								
								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>2,'ju'=>0))->order("id asc")->limit("$start,$pageSize")->select();
								// dump($list);
								// exit;
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码.
										"type"=> '1', //已通过.
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;
		          			case '2':
		          				//查询总条数
								$count = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0,'num'=>['exp',' >number ']])->count();
								// dump($count);
								// exit;
								if ($count == '0') {
									$count = 1;
								}
								// echo $count;
								// exit;
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0,'num'=>['exp',' >number ']])->order("time asc")->limit("$start,$pageSize")->select();
								$arr = [];
								foreach ($list as $key => $value) {
									if ($value != '') {
										// unset($list[$key]);
										$arr[] = array_filter($value);
									}
								}
								$arrlist = [];
								foreach ($arr as $key => $value) {
									if ($value['ju'] == '1') {
										$value['jname'] = $value['zname'];
										$value['jtime'] = $value['ztime'];
										$value['jtype'] = $value['ztype'];
										unset($value['zname']);
										unset($value['ztime']);
										unset($value['ztype']);
									}
									if ($value['ju'] == '3') {
										$value['jname'] = $value['xname'];
										$value['jtime'] = $value['xtime'];
										$value['jtype'] = $value['xtype'];
										unset($value['xname']);
										unset($value['xtime']);
										unset($value['xtype']);
									}
									if ($value['ju'] == '4') {
										$value['jname'] = $value['cname'];
										$value['jtime'] = $value['ctime'];
										$value['jtype'] = $value['ctype'];
										unset($value['cname']);
										unset($value['ctime']);
										unset($value['ctype']);
									}
									if ($value['ju'] == '5') {
										$value['jname'] = $value['gname'];
										$value['jtime'] = $value['gtime'];
										$value['jtype'] = $value['gtype'];
										unset($value['gname']);
										unset($value['gtime']);
										unset($value['gtype']);
									}
									if ($value['ju'] == '6') {
										$value['jname'] = $value['dname'];
										$value['jtime'] = $value['dtime'];
										$value['jtype'] = $value['dtype'];
										unset($value['dname']);
										unset($value['dtime']);
										unset($value['dtype']);
									}
									$arrlist[] = $value;
								}
								// echo '11';
								// exit;
								// $listarr = array_filter($list);
								// dump($arrlist);
								// exit;
								if (!empty($arrlist)) {
									
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '2', //已拒绝
										"data"=>$arrlist//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;				
		          			
		          		}
	            break;

	        

	          case '5':  //财务
	    //       		//查询总条数
					// $count = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>3,'ju'=>0))->count();
					// //每页显示数
					// $pageSize = 20;
					// //计算总页数
					// $a = ceil($count / $pageSize);
					// if ($page > $a) {
					// 	$page = $a;
					// }
					// //sql查询起始位置
					// $start = ($page - 1) * $pageSize;
					// //得到数据
					// $list = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>3,'ju'=>0))->order("id asc")->limit("$start,$pageSize")->select();
					// $ylist = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>3,'ju'=>0))->select();
	    //           	foreach ($ylist as  $v) {
	    //             	$coun += $v['zong']; 
	    //           	}
					// if (!empty($list)) {
						
					// 	$array = array(
					// 		"status"=>1,
					// 		'message'=>'请求成功',
					// 		"count"=>$count,//总条数
					// 		"pageSize"=>$pageSize, //每页显示条数
					// 		"thisPage"=>$page, //当前页码
					// 		"data"=>$list,//列表
					// 		"coun"=>$coun//总和
					// 		);
					// 	echo json_encode($array);
					// 	exit;
					// }else{
					// 	echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
					// 	exit;
					// }
	              	switch ($type) {
		          			case '0':
		          				//查询总条数
								$count = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>3,'ju'=>0))->count();
								if ($count == '0') {
									$count = 1;
								}
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>3,'ju'=>0))->order("id asc")->limit("$start,$pageSize")->select();
								
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									// dump($arr);
									// exit;
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '0', //待审批
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
									exit;
								}
		          				break;
		          			case '1':
		          				// echo $type;
		          				// exit;
		          				//查询总条数
								$count = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>4,'ju'=>0))->count();
								// dump($count);
								// exit;
								//每页显示数
								$pageSize = 20;
								if ($count == '0') {
									$count = 1;
								}
								//计算总页数
								$a = ceil($count / $pageSize);

								if ($page > $a) {
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
								
								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(array('num'=>array('exp',' >number '),'type'=>3,'look'=>4,'ju'=>0))->order("id asc")->limit("$start,$pageSize")->select();
								// dump($list);
								// exit;
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码.
										"type"=> '1', //已通过.
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;
		          			case '2':
		          				//查询总条数
								$count = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0,'num'=>['exp',' >number ']])->count();
								// dump($count);
								// exit;
								if ($count == '0') {
									$count = 1;
								}
								// echo $count;
								// exit;
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>$apost,'oa_look.type'=>3,'oa_look.look'=>0,'num'=>['exp',' >number ']])->order("time asc")->limit("$start,$pageSize")->select();
								$arr = [];
								foreach ($list as $key => $value) {
									if ($value != '') {
										// unset($list[$key]);
										$arr[] = array_filter($value);
									}
								}
								$arrlist = [];
								foreach ($arr as $key => $value) {
									if ($value['ju'] == '1') {
										$value['jname'] = $value['zname'];
										$value['jtime'] = $value['ztime'];
										$value['jtype'] = $value['ztype'];
										unset($value['zname']);
										unset($value['ztime']);
										unset($value['ztype']);
									}
									if ($value['ju'] == '3') {
										$value['jname'] = $value['xname'];
										$value['jtime'] = $value['xtime'];
										$value['jtype'] = $value['xtype'];
										unset($value['xname']);
										unset($value['xtime']);
										unset($value['xtype']);
									}
									if ($value['ju'] == '4') {
										$value['jname'] = $value['cname'];
										$value['jtime'] = $value['ctime'];
										$value['jtype'] = $value['ctype'];
										unset($value['cname']);
										unset($value['ctime']);
										unset($value['ctype']);
									}
									if ($value['ju'] == '5') {
										$value['jname'] = $value['gname'];
										$value['jtime'] = $value['gtime'];
										$value['jtype'] = $value['gtype'];
										unset($value['gname']);
										unset($value['gtime']);
										unset($value['gtype']);
									}
									if ($value['ju'] == '6') {
										$value['jname'] = $value['dname'];
										$value['jtime'] = $value['dtime'];
										$value['jtype'] = $value['dtype'];
										unset($value['dname']);
										unset($value['dtime']);
										unset($value['dtype']);
									}
									$arrlist[] = $value;
								}
								// echo '11';
								// exit;
								// $listarr = array_filter($list);
								// dump($arrlist);
								// exit;
								if (!empty($arrlist)) {
									
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '2', //已拒绝
										"data"=>$arrlist//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;				
		          			
		          		}
	            break;



	          case '9':  //职能总经理
	              	$mlist = M('auth_group')->where(['mtype'=>2])->select();
					switch ($type) {
		          			case '0':
		          				// $db = M("look");
				              	foreach ($mlist as $vn) {
				                	$ments[] =  $vn['title'];
				              	}
				               	$where = [
				                      'ment' => [
				                          'in',
				                          $ments
				                      ],
				                      'look' => 1,
				                      'type'=>3,
				                      'ju'   => 0

				                ];
		          				//查询总条数
								$count = M('look')->where($where)->count();
								if ($count == '0') {
									$count = 1;
								}
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where($where)->order("id asc")->limit("$start,$pageSize")->select();
								
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									// dump($arr);
									// exit;
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '0', //待审批
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
									exit;
								}
		          				break;
		          			case '1':
		          				foreach ($mlist as $vn) {
				                	$ments[] =  $vn['title'];
				              	}
				               	$where = [
				                      'ment' => [
				                          'in',
				                          $ments
				                      ],
				                      'look' => 2,
				                      'type'=>3,
				                      'ju'   => 0

				                ];
		          				// echo $type;
		          				// exit;
		          				//查询总条数
								$count = M('look')->where($where)->count();
								// dump($count);
								// exit;
								//每页显示数
								$pageSize = 20;
								if ($count == '0') {
									$count = 1;
								}
								//计算总页数
								$a = ceil($count / $pageSize);

								if ($page > $a) {
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
								
								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where($where)->order("id asc")->limit("$start,$pageSize")->select();
								// dump($list);
								// exit;
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码.
										"type"=> '1', //已通过.
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;
		          			case '2':
		          				foreach ($mlist as $vn) {
				                	$ments[] =  $vn['title'];
				              	}
				               	
		          				//查询总条数
								$count = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>['in',$ments],'oa_look.type'=>3,'oa_look.look'=>0])->count();
								// dump($count);
								// exit;
								if ($count == '0') {
									$count = 1;
								}
								// echo $count;
								// exit;
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>['in',$ments],'oa_look.type'=>3,'oa_look.look'=>0])->order("time asc")->limit("$start,$pageSize")->select();
								$arr = [];
								foreach ($list as $key => $value) {
									if ($value != '') {
										// unset($list[$key]);
										$arr[] = array_filter($value);
									}
								}
								$arrlist = [];
								foreach ($arr as $key => $value) {
									if ($value['ju'] == '1') {
										$value['jname'] = $value['zname'];
										$value['jtime'] = $value['ztime'];
										$value['jtype'] = $value['ztype'];
										unset($value['zname']);
										unset($value['ztime']);
										unset($value['ztype']);
									}
									if ($value['ju'] == '3') {
										$value['jname'] = $value['xname'];
										$value['jtime'] = $value['xtime'];
										$value['jtype'] = $value['xtype'];
										unset($value['xname']);
										unset($value['xtime']);
										unset($value['xtype']);
									}
									if ($value['ju'] == '4') {
										$value['jname'] = $value['cname'];
										$value['jtime'] = $value['ctime'];
										$value['jtype'] = $value['ctype'];
										unset($value['cname']);
										unset($value['ctime']);
										unset($value['ctype']);
									}
									if ($value['ju'] == '5') {
										$value['jname'] = $value['gname'];
										$value['jtime'] = $value['gtime'];
										$value['jtype'] = $value['gtype'];
										unset($value['gname']);
										unset($value['gtime']);
										unset($value['gtype']);
									}
									if ($value['ju'] == '6') {
										$value['jname'] = $value['dname'];
										$value['jtime'] = $value['dtime'];
										$value['jtype'] = $value['dtype'];
										unset($value['dname']);
										unset($value['dtime']);
										unset($value['dtype']);
									}
									$arrlist[] = $value;
								}
								// echo '11';
								// exit;
								// $listarr = array_filter($list);
								// dump($arrlist);
								// exit;
								if (!empty($arrlist)) {
									
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '2', //已拒绝
										"data"=>$arrlist//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;				
		          			
		          		}
	               
	               
	            break;

	          case '8':  //网络中心总经理
	          		$mlist = M('auth_group')->where(['mtype'=>1])->select();
					switch ($type) {
		          			case '0':
		          				// $db = M("look");
				              	foreach ($mlist as $vn) {
				                	$ments[] =  $vn['title'];
				              	}
				               	$where = [
				                      'ment' => [
				                          'in',
				                          $ments
				                      ],
				                      'look' => 1,
				                      'type'=>3,
				                      'ju'   => 0

				                ];
		          				//查询总条数
								$count = M('look')->where($where)->count();
								if ($count == '0') {
									$count = 1;
								}
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where($where)->order("id asc")->limit("$start,$pageSize")->select();
								
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									// dump($arr);
									// exit;
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '0', //待审批
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
									exit;
								}
		          				break;
		          			case '1':
		          				foreach ($mlist as $vn) {
				                	$ments[] =  $vn['title'];
				              	}
				               	$where = [
				                      'ment' => [
				                          'in',
				                          $ments
				                      ],
				                      'look' => 2,
				                      'type'=>3,
				                      'ju'   => 0

				                ];
		          				// echo $type;
		          				// exit;
		          				//查询总条数
								$count = M('look')->where($where)->count();
								// dump($count);
								// exit;
								//每页显示数
								$pageSize = 20;
								if ($count == '0') {
									$count = 1;
								}
								//计算总页数
								$a = ceil($count / $pageSize);

								if ($page > $a) {
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
								
								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where($where)->order("id asc")->limit("$start,$pageSize")->select();
								// dump($list);
								// exit;
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码.
										"type"=> '1', //已通过.
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;
		          			case '2':
		          				foreach ($mlist as $vn) {
				                	$ments[] =  $vn['title'];
				              	}
				               	
		          				//查询总条数
								$count = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>['in',$ments],'oa_look.type'=>3,'oa_look.look'=>0])->count();
								// dump($count);
								// exit;
								if ($count == '0') {
									$count = 1;
								}
								// echo $count;
								// exit;
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.ment'=>['in',$ments],'oa_look.type'=>3,'oa_look.look'=>0])->order("time asc")->limit("$start,$pageSize")->select();
								$arr = [];
								foreach ($list as $key => $value) {
									if ($value != '') {
										// unset($list[$key]);
										$arr[] = array_filter($value);
									}
								}
								$arrlist = [];
								foreach ($arr as $key => $value) {
									if ($value['ju'] == '1') {
										$value['jname'] = $value['zname'];
										$value['jtime'] = $value['ztime'];
										$value['jtype'] = $value['ztype'];
										unset($value['zname']);
										unset($value['ztime']);
										unset($value['ztype']);
									}
									if ($value['ju'] == '3') {
										$value['jname'] = $value['xname'];
										$value['jtime'] = $value['xtime'];
										$value['jtype'] = $value['xtype'];
										unset($value['xname']);
										unset($value['xtime']);
										unset($value['xtype']);
									}
									if ($value['ju'] == '4') {
										$value['jname'] = $value['cname'];
										$value['jtime'] = $value['ctime'];
										$value['jtype'] = $value['ctype'];
										unset($value['cname']);
										unset($value['ctime']);
										unset($value['ctype']);
									}
									if ($value['ju'] == '5') {
										$value['jname'] = $value['gname'];
										$value['jtime'] = $value['gtime'];
										$value['jtype'] = $value['gtype'];
										unset($value['gname']);
										unset($value['gtime']);
										unset($value['gtype']);
									}
									if ($value['ju'] == '6') {
										$value['jname'] = $value['dname'];
										$value['jtime'] = $value['dtime'];
										$value['jtype'] = $value['dtype'];
										unset($value['dname']);
										unset($value['dtime']);
										unset($value['dtype']);
									}
									$arrlist[] = $value;
								}
								// echo '11';
								// exit;
								// $listarr = array_filter($list);
								// dump($arrlist);
								// exit;
								if (!empty($arrlist)) {
									
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '2', //已拒绝
										"data"=>$arrlist//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;				
		          			
		          		}
	                
	            break;
	          case '6':  //董事办
	              	switch ($type) {
		          			case '0':
		          				//查询总条数
								$count = M('look')->where(['type'=>3,'look'=>5,'ju'=>0])->count();
								if ($count == '0') {
									$count = 1;
								}
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(['type'=>3,'look'=>5,'ju'=>0])->order("id asc")->limit("$start,$pageSize")->select();
								
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									// dump($arr);
									// exit;
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '0', //待审批
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'请求失败',"data"=>[]));
									exit;
								}
		          				break;
		          			case '1':
		          				// echo $type;
		          				// exit;
		          				//查询总条数
								$count = M('look')->where(['type'=>3,'look'=>6,'ju'=>0])->count();
								// dump($count);
								// exit;
								//每页显示数
								$pageSize = 20;
								if ($count == '0') {
									$count = 1;
								}
								//计算总页数
								$a = ceil($count / $pageSize);

								if ($page > $a) {
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
								
								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->where(['type'=>3,'look'=>6,'ju'=>0])->order("id asc")->limit("$start,$pageSize")->select();
								// dump($list);
								// exit;
								if (!empty($list)) {
									$arr = [];
									foreach ($list as $key => $value) {
										$value['jname'] = '';
										$value['jcent'] = '';
										$arr[] = $value;
									}
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码.
										"type"=> '1', //已通过.
										"data"=>$arr//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;
		          			case '2':
		          				//查询总条数
								$count = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>'6','oa_look.type'=>3,'oa_look.look'=>0])->count();
								// dump($count);
								// exit;
								if ($count == '0') {
									$count = 1;
								}
								// echo $count;
								// exit;
								//每页显示数
								$pageSize = 20;
								//计算总页数
								$a = ceil($count / $pageSize);
								
								if ($page > $a) {
									// $page = $a;
									echo json_encode(array("status"=>1,'message'=>'暂无数据',"data"=>[]));
									exit;
								}

								//sql查询起始位置
								$start = ($page - 1) * $pageSize;
								// echo $start;
								// exit;
								//得到数据
								$list = M('look')->join('oa_yue as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>'6','oa_look.type'=>3,'oa_look.look'=>0])->order("time asc")->limit("$start,$pageSize")->select();
								$arr = [];
								foreach ($list as $key => $value) {
									if ($value != '') {
										// unset($list[$key]);
										$arr[] = array_filter($value);
									}
								}
								$arrlist = [];
								foreach ($arr as $key => $value) {
									if ($value['ju'] == '1') {
										$value['jname'] = $value['zname'];
										$value['jtime'] = $value['ztime'];
										$value['jtype'] = $value['ztype'];
										unset($value['zname']);
										unset($value['ztime']);
										unset($value['ztype']);
									}
									if ($value['ju'] == '3') {
										$value['jname'] = $value['xname'];
										$value['jtime'] = $value['xtime'];
										$value['jtype'] = $value['xtype'];
										unset($value['xname']);
										unset($value['xtime']);
										unset($value['xtype']);
									}
									if ($value['ju'] == '4') {
										$value['jname'] = $value['cname'];
										$value['jtime'] = $value['ctime'];
										$value['jtype'] = $value['ctype'];
										unset($value['cname']);
										unset($value['ctime']);
										unset($value['ctype']);
									}
									if ($value['ju'] == '5') {
										$value['jname'] = $value['gname'];
										$value['jtime'] = $value['gtime'];
										$value['jtype'] = $value['gtype'];
										unset($value['gname']);
										unset($value['gtime']);
										unset($value['gtype']);
									}
									if ($value['ju'] == '6') {
										$value['jname'] = $value['dname'];
										$value['jtime'] = $value['dtime'];
										$value['jtype'] = $value['dtype'];
										unset($value['dname']);
										unset($value['dtime']);
										unset($value['dtype']);
									}
									$arrlist[] = $value;
								}
								// echo '11';
								// exit;
								// $listarr = array_filter($list);
								// dump($arrlist);
								// exit;
								if (!empty($arrlist)) {
									
									$array = array(
										"status"=>1,
										'message'=>'请求成功',
										"count"=>$count,//总条数
										"pageSize"=>$pageSize, //每页显示条数
										"thisPage"=>$page, //当前页码
										"type"=> '2', //已拒绝
										"data"=>$arrlist//列表
										);
									echo json_encode($array);
									exit;
								}else{
									echo json_encode(array("status"=>0,'message'=>'暂无数据',"data"=>[]));
									exit;
								}
		          				break;				
		          			
		          		}
	            break;

	          }
	}

	/**
	 * [ysh 月度需求申请审批]
	 * @return [type] [description]
	 */
	public function ysh()
	{
		$sid = $_POST['id'];
		$ulist = M('member')->where(['uid'=>$_GET['uid']])->select();
		$gid = M('auth_group_access')->where(['uid'=>$_GET['uid']])->select();
		$glist = M('auth_group')->where(['id'=>$gid[0]['group_id']])->select();
		$apost = $glist[0]['post'];
		$data['sid'] = $sid;
		$data['stype'] = '1';
		$ss = M('yue')->where(['sid'=>$sid])->select();
		switch ($ulist[0]['m_type']) {
			case '2': //主管
				$data['ztype'] = $ulist[0]['m_type'];
				$data['zname'] = $ulist[0]['user'];
				$data['ztime'] = date('Y-m-d');
				$look['look'] = '1';
				if (M('yue')->add($data) > 0) {
					if (M('look')->where(['id'=>$sid])->save($look) > 0) {
						echo json_encode(array("status"=>1,'message'=>'审批通过',"data"=>[]));
						exit;
					}
				}else{
					echo json_encode(array("status"=>0,'message'=>'审批失败',"data"=>[]));
					exit;
				}
				break;
			case '9': //职能总经理
				$sss = M('yue')->where(['sid'=>$sid])->select();
				if (empty($sss[0]['cname'])) {
					$data['jtype'] = $ulist[0]['m_type'];
					$data['jname'] = $ulist[0]['user'];
					$data['jtime'] = date('Y-m-d');
					$look['look'] = '2';
				
						if (M('yue')->where(['sid'=>$sid])->save($data) > 0) {
							if (M('look')->where(['id'=>$sid])->save($look) > 0) {
								echo json_encode(array("status"=>1,'message'=>'审批通过',"data"=>[]));
								exit;
							}
						}else{
							echo json_encode(array("status"=>0,'message'=>'审批失败',"data"=>[]));
							exit;
						}
				}else{
					$data['gtype'] = $ulist[0]['m_type'];
					$data['gname'] = $ulist[0]['user'];
					$data['gtime'] = date('Y-m-d');
					$look['look'] = '5';
				
						if (M('yue')->where(['sid'=>$sid])->save($data) > 0) {
							if (M('look')->where(['id'=>$sid])->save($look) > 0) {
								echo json_encode(array("status"=>1,'message'=>'审批通过',"data"=>[]));
								exit;
							}
						}else{
							echo json_encode(array("status"=>0,'message'=>'审批失败',"data"=>[]));
							exit;
						}
				}
				
				
				break;
			case '8': //网络总经理
				
				$data['jtype'] = $ulist[0]['m_type'];
				$data['jname'] = $ulist[0]['user'];
				$data['jtime'] = date('Y-m-d');
				$look['look'] = '2';
			
					if (M('yue')->where(['sid'=>$sid])->save($data) > 0) {
						if (M('look')->where(['id'=>$sid])->save($look) > 0) {
							echo json_encode(array("status"=>1,'message'=>'审批通过',"data"=>[]));
							exit;
						}
					}else{
						echo json_encode(array("status"=>0,'message'=>'审批失败',"data"=>[]));
						exit;
					}
				
				break;

			case '3': //经理
				switch ($apost) {
					case '行政中心':
					// echo '11';
					// exit;
							$data['jtype'] = $ulist[0]['m_type'];
							$data['jname'] = $ulist[0]['user'];
							$data['jtime'] = date('Y-m-d');
							$look['look'] = '2';
							// dump($data);
							// exit;
							
								if (M('yue')->where(['sid'=>$sid])->save($data) > 0) {
									if (M('look')->where(['id'=>$sid])->save($look) > 0) {
										echo json_encode(array("status"=>1,'message'=>'审批通过',"data"=>[]));
										exit;
									}
								}else{
									echo json_encode(array("status"=>0,'message'=>'审批失败',"data"=>[]));
									exit;
								}
							
						break;
					case '采购中心':
							$data['jtype'] = $ulist[0]['m_type'];
							$data['jname'] = $ulist[0]['user'];
							$data['jtime'] = date('Y-m-d');
							$look['look'] = '2';
						
								if (M('yue')->where(['sid'=>$sid])->save($data) > 0) {
									if (M('look')->where(['id'=>$sid])->save($look) > 0) {
										echo json_encode(array("status"=>1,'message'=>'审批通过',"data"=>[]));
										exit;
									}
								}else{
									echo json_encode(array("status"=>0,'message'=>'审批失败',"data"=>[]));
									exit;
								}
							
						break;
					case '财务中心':
							$data['jtype'] = $ulist[0]['m_type'];
							$data['jname'] = $ulist[0]['user'];
							$data['jtime'] = date('Y-m-d');
							$look['look'] = '2';
						
								if (M('yue')->where(['sid'=>$sid])->save($data) > 0) {
									if (M('look')->where(['id'=>$sid])->save($look) > 0) {
										echo json_encode(array("status"=>1,'message'=>'审批通过',"data"=>[]));
										exit;
									}
								}else{
									echo json_encode(array("status"=>0,'message'=>'审批失败',"data"=>[]));
									exit;
								}
							
						break;
					
				}
			
				break;


			case '4': //行政

				$arr['xtype'] = $ulist[0]['m_type'];
				$arr['xname'] = $ulist[0]['user'];
				$arr['xtime'] = date('Y-m-d');
				$look['look'] = '3';
				if (M('yue')->where(['sid'=>$sid])->save($arr) > 0) {
					if (M('look')->where(['id'=>$sid])->save($look) > 0) {
						echo json_encode(array("status"=>1,'message'=>'审批通过',"data"=>[]));
						exit;
					}
				}else{
					echo json_encode(array("status"=>0,'message'=>'审批失败',"data"=>[]));
					exit;
				}
				break;

			case '5': //财务
				$arr['ctype'] = $ulist[0]['m_type'];
				$arr['cname'] = $ulist[0]['user'];
				$arr['ctime'] = date('Y-m-d');
				$look['look'] = '4';
				if (M('yue')->where(['sid'=>$sid])->save($arr) > 0) {
					if (M('look')->where(['id'=>$sid])->save($look) > 0) {
						echo json_encode(array("status"=>1,'message'=>'审批通过',"data"=>[]));
						exit;
					}
				}else{
					echo json_encode(array("status"=>0,'message'=>'审批失败',"data"=>[]));
					exit;
				}
				break;
			case '6': //董事办
				$arr['dtype'] = $ulist[0]['m_type'];
				$arr['dname'] = $ulist[0]['user'];
				$arr['dtime'] = date('Y-m-d');
				$look['look'] = '6';
				if (M('yue')->where(['sid'=>$sid])->save($arr) > 0) {
					if (M('look')->where(['id'=>$sid])->save($look) > 0) {
						echo json_encode(array("status"=>1,'message'=>'审批通过',"data"=>[]));
						exit;
					}
				}else{
					echo json_encode(array("status"=>0,'message'=>'审批失败',"data"=>[]));
					exit;
				}
				break;
			
		}
	}






	/**
	 * [yju 月度需求审批拒绝]
	 * @return [uid] [审批人ID]
	 * @return [ID] [审批信息id]
	 */
	public function yju()
	{

		$ulist = M('member')->where(['uid'=>$_GET['uid']])->select();
		$alist = M('auth_group_access')->where(['uid'=>$_GET['uid']])->select();
		$glist = M('auth_group')->where(['id'=>$alist[0]['group_id']])->select();
		$llist = M('look')->where(['id'=>$_GET['id']])->find();
		$data['stype'] = '2';
		$data['cent'] = $_GET['cent'];
		// dump($llist);
		// exit;
		switch ($ulist[0]['m_type']) {
			case '2':  //主管
				$data['ztype'] = $ulist[0]['m_type'];
						
				$data['zname'] = $ulist[0]['user'];
				$data['ztime'] = date('Y-m-d');
				$data['sid'] = $_GET['id'];
				$data['cent'] = $_GET['cent'];
				// $data['stype'] = '2';
				$look['ju'] = '1';
								// dump($data);

				if (M('yue')->add($data) > 0) {
					if (M('look')->where(['id'=>$_GET['id']])->save($look) > 0) {
						echo json_encode(array("status"=>1,'message'=>'拒绝成功',"data"=>[]));
						exit;
					}
				}else{
						echo json_encode(array("status"=>2,'message'=>'拒绝失败',"data"=>[]));
						exit;
				}
				break;
			case '3': //经理/总监
				switch ($glist[0]['post']) {
					case '行政中心':
						// $sid = $_GET['id'];	
						$ylist = M('yue')->where(['sid'=>$_GET['id']])->find();
						// dump($ylist);
						// exit;
						if (empty($ylist['jname'])) {
							$data['jtype'] = $ulist[0]['m_type'];
							$data['jname'] = $ulist[0]['user'];
							$data['jtime'] = date('Y-m-d');
							$look['ju'] = '2';
							if (M('yue')->where(['sid'=>$_GET['id']])->save($data) > 0) {
								if (M('look')->where(['id'=>$_GET['id']])->save($look) > 0) {
									echo json_encode(array("status"=>1,'message'=>'拒绝成功',"data"=>[]));
									exit;
								}
							}else{
								echo json_encode(array("status"=>2,'message'=>'拒绝失败',"data"=>[]));
								exit;
							}
						}else{
							$data['xtype'] = $ulist[0]['m_type'];
							$data['xname'] = $ulist[0]['user'];
							$data['xtime'] = date('Y-m-d');
							$look['ju'] = '3';
							if (M('yue')->where(['sid'=>$_GET['id']])->save($data) > 0) {
								if (M('look')->where(['id'=>$_GET['id']])->save($look) > 0) {
									echo json_encode(array("status"=>1,'message'=>'拒绝成功',"data"=>[]));
									exit;
								}
							}else{
								echo json_encode(array("status"=>2,'message'=>'拒绝失败',"data"=>[]));
								exit;
							}
						}
						
						break;
					case '采购中心':
						$data['jtype'] = $ulist[0]['m_type'];
						$data['jname'] = $ulist[0]['user'];
						$data['jtime'] = date('Y-m-d');
						$look['ju'] = '2';
						if (M('yue')->where(['sid'=>$_GET['id']])->save($data) > 0) {
							if (M('look')->where(['id'=>$_GET['id']])->save($look) > 0) {
								echo json_encode(array("status"=>1,'message'=>'拒绝成功',"data"=>[]));
									exit;
							}
						}else{
							echo json_encode(array("status"=>2,'message'=>'拒绝失败',"data"=>[]));
								exit;
						}
						break;
					case '财务中心':
							$ylist = M('yue')->where(['sid'=>$_GET['id']])->find();
							if (empty($ylist['jname'])) {
								$data['jtype'] = $ulist[0]['m_type'];
								$data['jname'] = $ulist[0]['user'];
								$data['jtime'] = date('Y-m-d');
								$look['ju'] = '2';
								if (M('yue')->where(['sid'=>$_GET['id']])->save($data) > 0) {
									if (M('look')->where(['id'=>$_GET['id']])->save($look) > 0) {
										echo json_encode(array("status"=>1,'message'=>'拒绝成功',"data"=>[]));
										exit;
									}
								}else{
									echo json_encode(array("status"=>2,'message'=>'拒绝失败',"data"=>[]));
									exit;
								}
							}else{
								$data['ctype'] = $ulist[0]['m_type'];
								$data['cname'] = $ulist[0]['user'];
								$data['ctime'] = date('Y-m-d');
								$look['ju'] = '4';
								if (M('yue')->where(['sid'=>$_GET['id']])->save($data) > 0) {
									if (M('look')->where(['id'=>$_GET['id']])->save($look) > 0) {
										echo json_encode(array("status"=>1,'message'=>'拒绝成功',"data"=>[]));
										exit;
									}
								}else{
									echo json_encode(array("status"=>2,'message'=>'拒绝失败',"data"=>[]));
									exit;
								}
							}
							
						
						break;
					
				}

				break;
			
			
			case '9':  //职能总经理
				$ylist = M('yue')->where(['sid'=>$_GET['id']])->find();
				// dump($_GET['id']);
				// exit;
				if (empty($ylist['jname'])) {
					$data['jtype'] = $ulist[0]['m_type'];
					$data['jname'] = $ulist[0]['user'];
					$data['jtime'] = date('Y-m-d');
					$look['ju'] = '2';
									// dump($data);

					if (M('yue')->where(['sid'=>$_GET['id']])->save($data) > 0) {
						if (M('look')->where(['id'=>$_GET['id']])->save($look) > 0) {
							echo json_encode(array("status"=>1,'message'=>'拒绝成功',"data"=>[]));
							exit;
						}
					}else{
						echo json_encode(array("status"=>2,'message'=>'拒绝失败',"data"=>[]));
									exit;
					}
				}else{
					$data['gtype'] = $ulist[0]['m_type'];
					$data['gname'] = $ulist[0]['user'];
					$data['gtime'] = date('Y-m-d');
					$look['ju'] = '5';
									// dump($data);

					if (M('yue')->where(['sid'=>$_GET['id']])->save($data) > 0) {
						if (M('look')->where(['id'=>$_GET['id']])->save($look) > 0) {
							echo json_encode(array("status"=>1,'message'=>'拒绝成功',"data"=>[]));
							exit;
						}
					}else{
						echo json_encode(array("status"=>2,'message'=>'拒绝失败',"data"=>[]));
									exit;
					}
				}
				
				break;
			

				
		}
	}






	/**
	 * [kadd 库存添加]
	 * @return [type] [description]
	 */
	public function kadd()
	{
		$list = $_GET;
		// foreach ($_GET as $key => $vv) {	
	 //      		switch ($vv['x_type']) {
	 //      			case '办公用品':
	 //      				$vv['x_type'] = '1';
	      				
	 //      				break;
	 //      			case '劳保用品':
	 //      				$vv['x_type'] = '2';
	 //      				break;
	 //      			case '招待用品':
	 //      				$vv['x_type'] = '3';
	 //      				break;
	 //      		}

	 //      		// dump($vv);
	 //      		$arr[] = $vv;
	 //      }
	    if (M('stock')->add($arr) > 0) {
	    	echo json_encode(array("status"=>1,'message'=>'添加成功',"data"=>[]));
							exit;
	    }else{
	    	echo json_encode(array("status"=>2,'message'=>'添加失败',"data"=>[]));
									exit;
	    }
	}




}